package e

var MsgFlags = map[int]string{
	SUCCESS:        "ok",
	ERROR:          "fail",
	INVALID_PARAMS: "请求参数错误",

	ERROR_TOKEN_GENERATE: "登录token生成失败",
	ERROR_TOKEN_TIMEOUT:  "登录token已过期，请重新登录",
	ERROR_TOKEN_FAIL:     "登录token鉴权失败",
	ERROR_TOKEN:          "登录token错误",

	ERROR_UPLOAD_SIZE:  "上传文件超出大小",
	ERROR_UPLOAD_EXTS:  "上传文件类型不符合",
	ERROR_UPLOAD_CHECK: "上传文件检测错误",
	ERROR_UPLOAD_SAVE:  "上传文件保存失败",

	ERROR_USER_EXIST:     "用户已存在",
	ERROR_USER_NOT_EXIST: "用户不存在",
	ERROR_USER_GET:       "获取用户失败",
	ERROR_USER_PASSWORD:  "用户密码错误",

	ERROR_DEVICE_CHECK_EXIST: "检查设备存在失败",
	ERROR_DEVICE_EXIST:       "设备[sn]已存在",
	ERROR_DEVICE_NOT_EXIST:   "设备不存在",
	ERROR_DEVICE_GET_ALL:     "获取所以设备失败",
	ERROR_DEVICE_ADD:         "添加设备失败",
	ERROR_DEVICE_EDIT:        "修改设备失败",
	ERROR_DEVICE_DELETE:      "删除设备失败",

	ERROR_EMQX_GET_CLIENTS: "获取EMQX在线情况失败",
}

// GetMsg get error information based on Code
func GetMsg(code int) string {
	msg, ok := MsgFlags[code]
	if ok {
		return msg
	}

	return MsgFlags[ERROR]
}
